<script type="text/javascript" src="{$base_dir}js/jquery.ajaxupload-3.0.js"></script>
<script src="{$base_dir}js/jquery.lightbox-0.5.min.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="{$base_dir}/css/jquery.lightbox-0.5.css"/>
<script type="text/javascript">
{literal}
    $(document).ready(function(){        
          $('#saveRadResultBtn').click(function(){
                saveMetaData();
          });
          
          var upload    =   new AjaxUpload('#uploadRadImageBtn',{
                action: '../RadResult/UploadImageAjax?set_ajax_view',
                selectChange: function(file, ext) {
                    
                },
                autoSubmit: true,
                responseType: "json",
                onSubmit:   function(file, extension){
                    if ($('#radTicketItemListLbx').val() == null) {
                        return false;
                    }
                    else {
                        this.setData({'radTicketItemId': $('#radTicketItemListLbx').val()});
                    }
                },
                onComplete: function(file, data) {
                    if (data.error.code == 'OK') {    
                        var rowNum  =   $('#radImageTbl tbody tr').length;             
                        var colNum  =   $('#radImageTbl tbody tr:last td').length;
                        var col     =   "<td id='" +  data.result.radImageId + "'>";
                        col    +=  "<div class='thumbnail_wrapper' style='height: 170px; width: 170px;'>";
                        col    +=  "<a class='gallery' href='" + data.result.fullUrl + "'><img border='0' src='" + data.result.thumbnailUrl + "' /></a>";
                        col    +=  "</div><br/>";
                        col    +=  "<div style='text-align: right; width: 170px;'>";
                        col    +=  "<a href='javascript:deleteRadImage(" + data.result.radImageId + ");'><img border='0' src='../images/round_delete_24x24.png' /></a>";
                        col    +=  "</div>";
                        col    +=  "</td>";
                        if (rowNum > 0 && colNum < 3) {
                            // Add column to the last row                           
                            $('#radImageTbl tbody tr:last').append(col);                           
                        }
                        else {
                            // Add new row
                            row    =   '<tr>' + col + '</tr>';                      
                            $('#radImageTbl tbody').append(row);
                        }
                        $('#radImageListDiv a.gallery').lightBox({
                            imageLoading: '../images/lightbox-ico-loading.gif',
                            imageBtnClose: '../images/lightbox-btn-close.gif',
                            imageBtnPrev: '../images/lightbox-btn-prev.gif',
                            imageBtnNext: '../images/lightbox-btn-next.gif',
                            imageBlank: '../images/lightbox-blank.gif'
                         });
                    }
                    else {
                        displayError(data.error.mess);
                    }
                }            
          });
    });
{/literal}
</script>
{include file="radiology/element_result_input_conclusion.html"}